package context

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/data/binding"
)

var WContext *WeightContext

type WeightContext struct {
	Wc map[string]*BindContext
}
type BindContext struct {
	bind   binding.String
	Weight fyne.CanvasObject
	Id     string
	Save   bool
}

func NewBindContext(bind binding.String, weight fyne.CanvasObject, id string, save bool) *BindContext {
	return &BindContext{bind: bind, Weight: weight, Id: id, Save: save}
}

func NewWeightContext() *WeightContext {
	return &WeightContext{Wc: make(map[string]*BindContext)}
}

func (context *WeightContext) Put(id string, b *BindContext) {
	context.Wc[id] = b
}

func (context *WeightContext) GetStr(id string) (string, error) {
	bind := context.Wc[id]
	return bind.bind.Get()
}
func init() {
	WContext = NewWeightContext()
}
